➤ Resource Quotas


$ kubectl create ns example-namespace


$ kubectl apply -f ResourceQuota.yml


$ kubectl get resourcequota resource-quota-example -n example-namespace
NAME                     AGE   REQUEST                                                LIMIT
resource-quota-example   11m   pods: 0/1, requests.cpu: 0/2, requests.memory: 0/5Gi   limits.cpu: 0/4, limits.memory: 0/10Gi


$ kubectl describe ns example-namespace
Name:         example-namespace
Labels:       kubernetes.io/metadata.name=example-namespace
Annotations:  <none>
Status:       Active
Resource Quotas
  Name:            resource-quota-example
  Resource         Used  Hard
  --------         ---   ---
  limits.cpu       0     4
  limits.memory    0     10Gi
  pods             0     1
  requests.cpu     0     2
  requests.memory  0     5Gi
No LimitRange resource.


$ kubectl apply -f Deployment.yaml


$ kubectl get all -n example-namespace
NAME                              READY   STATUS    RESTARTS   AGE
pod/quota-test-7b87fc5699-5bc5v   1/1     Running   0          8s

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/quota-test   1/2     1            1           8s

NAME                                    DESIRED   CURRENT   READY   AGE
replicaset.apps/quota-test-7b87fc5699   2         1         1       8s


$ kubectl describe rs quota-test-7b87fc5699 -n example-namespace
....
....
....
Events:
  Type     Reason            Age                 From                   Message
  ----     ------            ----                ----                   -------
  Normal   SuccessfulCreate  12m                 replicaset-controller  Created pod: quota-test-7b87fc5699-5bc5v
  Warning  FailedCreate      12m                 replicaset-controller  Error creating: pods "quota-test-5477d458d5-q7v2d" is forbidden: exceeded quota: resource-quota-example, requested: pods=1, used: pods=1, limited: pods=1


Error in ReplicaSet :-
Warning  FailedCreate      8s (x5 over 39s)  replicaset-controller  (combined from similar events): Error creating: pods "quota-test-7b87fc5699-7nqsk" is forbidden: exceeded quota: resource-quota-example, requested: pods=1, used: pods=1, limited: pods=1

This means you cannot create more than the specified number of Pods. The same principle applies to CPU and memory limits.
If need to create more Pods or increase the resource allocation, you will need to update the Resource Quota accordingly.



[LINKS]
https://medium.com/@muppedaanvesh/a-hand-on-guide-to-kubernetes-resource-quotas-limit-ranges-%EF%B8%8F-8b9f8cc770c5
